<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "read_option".
 *
 * @property integer $id
 * @property integer $read_question_id
 * @property string $options
 * @property string $content
 * @property integer $is_correct
 *
 * @property ReadQuestion $readQuestion
 */
class ReadOption extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'read_option';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['read_question_id', 'options', 'content'], 'required'],
            [['read_question_id', 'is_correct'], 'integer'],
            [['content'], 'string'],
            [['options'], 'string', 'max' => 1],
            [['read_question_id'], 'exist', 'skipOnError' => true, 'targetClass' => ReadQuestion::className(), 'targetAttribute' => ['read_question_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'read_question_id' => 'Read Question ID',
            'options' => 'Options',
            'content' => 'Content',
            'is_correct' => 'Is Correct',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getReadQuestion()
    {
        return $this->hasOne(ReadQuestion::className(), ['id' => 'read_question_id']);
    }
}
